package com.qiaoas.springbootmybatisbymysqlcrud.Mapper;


import com.qiaoas.springbootmybatisbymysqlcrud.Bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

@Mapper
@Component
public interface  UserMapper {

    @Insert("insert into user(no,name,age) values(#{no},#{name},#{age})")
    int add(User user);

    @Update("update user set name=#{name} where no = #{no}")
    int update(User user);

    @Delete("delete from user where no = #{no}")
    int delete(int no);

    @Select("select * from user")
    @Results(id = "user", value = {
            @Result(property = "no", column = "no", javaType = Integer.class),
            @Result(property = "name", column = "name", javaType = String.class),
            @Result(property = "age", column = "age", javaType = Integer.class)
    })
    User getUser(int no);
}
